<?php

namespace Jinxing\Admin\Traits;

use Illuminate\Http\Request;

trait ExceptTrait
{
    /**
     * Determine if the request has a URI that should pass through CSRF verification.
     *
     * @param Request $request     请求类
     * @param array   $except_list 需要排除的列表
     *
     * @return bool
     */
    protected function inExceptArray($request, $except_list = [])
    {
        foreach ($except_list as $except) {
            if ($except !== '/') {
                $except = trim($except, '/');
            }

            if ($request->fullUrlIs($except) || $request->is($except)) {
                return true;
            }
        }

        return false;
    }
}
